package com.zmn.brs.common.enums;

import java.util.Optional;
import java.util.stream.Stream;

/**
 * 类描述：预警等级枚举
 * @author chongw
 * @since 2021/06/10 13:47
 */
public enum WronLevelEnum {

    ONE(1, "一级预警"),
    TWO(2, "二级预警"),
    THREE(3, "三级预警");

    /**
     * 类型
     */
    private final Integer levelId;

    /**
     * 类型名
     */
    private final String levelName;

    WronLevelEnum(Integer levelId, String levelName) {

        this.levelId = levelId;
        this.levelName = levelName;
    }

    public Integer getLevelId() {

        return levelId;
    }

    public String getLevelName() {

        return levelName;
    }

    public static WronLevelEnum getLevelEnum(Integer levelId) {

        Optional<WronLevelEnum> optional = Stream.of(WronLevelEnum.values()).filter(e -> e.getLevelId().equals(levelId)).findFirst();
        return optional.orElse(null);
    }

    public static String getLevelName(Integer levelId) {
        WronLevelEnum of = getLevelEnum(levelId);
        return of == null ? null : of.getLevelName();
    }
}
